package org.xue.snowmall.order.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.web.bind.annotation.*;
import org.xue.snowmall.common.utils.R;

import org.springframework.beans.factory.annotation.Autowired;

import entity.GoodsOrderEntity;
import org.xue.snowmall.order.service.GoodsOrderService;
import org.xue.snowmall.common.utils.PageUtils;


/**
 * 
 *
 * @author zy
 * @email 2067065884@qq.com
 * @date 2021-09-23 17:11:09
 */
@RestController
@RequestMapping("order/goodsorder")
public class GoodsOrderController {
    @Autowired
    private GoodsOrderService goodsOrderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils<GoodsOrderEntity> page = goodsOrderService.queryPage(params);

        return R.ok().put("page", page);
    }


    @GetMapping("/createGroupOrder")
    public R createGroupOrder(@RequestParam ("gsmGroupId") Long gsmGroupId) {
        return goodsOrderService.createGroupOrder(gsmGroupId);
    }
    /**
     * 信息
     */
    @RequestMapping("/info/{osmId}")
    public R info(@PathVariable("osmId") Long osmId){
		GoodsOrderEntity goodsOrder = goodsOrderService.getById(osmId);

        return R.ok().put("goodsOrder", goodsOrder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody GoodsOrderEntity goodsOrder){
		goodsOrderService.save(goodsOrder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody GoodsOrderEntity goodsOrder){
		goodsOrderService.updateById(goodsOrder);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] osmIds){
		goodsOrderService.removeByIds(Arrays.asList(osmIds));

        return R.ok();
    }

}
